<template>
<view class="container">
  <view class="main">
    <!-- 余额 -->
    <view class="header">
      <text class="title">可用微信代金券余额(元)</text>
      <text class="amount">{{balance}}</text>
    </view>
    <!-- 账单 -->
    <view class="item-cont">
      <block v-for="(item, index) in billList" :key="index">
        <view class="item">
          <view class="left">{{item.op === 1 ? '充值': '消费'}}</view>
          <view class="mid">
            <view class="mid-top">{{`￥${item.amount}/￥${item.balance}`}}</view>
            <view class="mid-mid">支付/余额</view>
            <view class="mid-bot">{{item.memo}}</view>
          </view>
          <view class="right">
            <view class="right-top">发生时间/{{item.createTime.replace('T', ' ')}}</view>
            <view class="right-mid">失效时间/{{item.exp? item.exp.replace('T', ' ') : '-'}}</view>
            <view class="right-bot">订单商品/{{item.orderNumber}}</view>
          </view>
        </view>
      </block>
    </view>
  </view>
</view>
</template>

<script>
var http = require("../../utils/http.js");
export default {
  data() {
    return {
      pages: 0,
      current: 1,
      balance: 0,
      billList: [],
    };
  },
  components: {},
  props: {},
  onLoad: function (option) {
    this.setData({
      balance: option.balance
    })
  },
  //加载订单列表
  onShow: function () {
    var ths = this;
    uni.showLoading();
    var params = {
      url: "/p/user/pageByBalanceLog",
      method: "GET",
      data: {
        current: 1,
        size: 10
      },
      callBack: function (res) {
        console.log(res)
        ths.setData({
          billList: res.records
        });
        uni.hideLoading();
      }
    };
    http.request(params);
  },
  methods: {}
};
</script>
<style>
@import "bill.css";
</style>
